package com.traffic.service.impl;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.traffic.constant.Status;

import com.traffic.entity.Leaderboard;

import com.traffic.exception.BaseException;


import com.traffic.mapper.LeaderboardMapper;
import com.traffic.service.LeaderboardService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service
public class LeaderoardServiceImpl extends ServiceImpl<LeaderboardMapper,Leaderboard> implements LeaderboardService {

    @Autowired
    LeaderboardMapper leaderboardMapper;

    @Override
    public List<Object> queryTargetLeaderboard(String type) {

        QueryWrapper<Leaderboard> wrapper = new QueryWrapper<>();

        List<Object> led = leaderboardMapper.selectObjs(wrapper.select(type).orderByAsc("id").gt(type,0));

        return led;
    }

    @Override
    public Object queryMyTypeRank(String type, Long userid) {
        QueryWrapper<Leaderboard> wrapper = new QueryWrapper<>();
        Object myrank = leaderboardMapper.selectObjs(wrapper.select("user_id").eq(type,userid));

        return myrank;
    }
}
